Skip to content

fix: Rename all the --terragrunt- flags#4203

Merged
yhakbar merged 23 commits intomainfrom
fix/cleaning-up-old-flags
May 2, 2025
Merged

fix: Rename all the --terragrunt- flags#4203
yhakbar merged 23 commits intomainfrom
fix/cleaning-up-old-flags

Conversation

@yhakbar
Copy link
Copy Markdown
Collaborator

@yhakbar yhakbar commented Apr 24, 2025

Description

Goes through all the legacy --terragrunt- flags and renames them to remove the terragrunt- prefix.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Updated all docs and tests to use non-prefixed flags.

Summary by CodeRabbit

  • Documentation
    • Updated all references to CLI flags and environment variables to use simplified, standardized names (e.g., --terragrunt-iam-role--iam-role, TERRAGRUNT_IAM_ROLETG_IAM_ROLE).
    • Improved documentation examples and consistency for CLI usage, environment variables, and feature explanations.
    • Added and corrected sections for new commands and features.
  • Bug Fixes
    • Corrected flag and environment variable names in error messages and logs for improved clarity.
  • Style
    • Standardized CLI flag names across comments, logs, and documentation for consistency.
  • Tests
    • Updated all test cases and helper scripts to use the new flag and environment variable naming conventions.
    • Removed deprecated test cases and improved test clarity.
  • Chores
    • Performed minor formatting and whitespace corrections in documentation.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
terragrunt-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 1:18pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 24, 2025

📝 Walkthrough

Walkthrough

This change is a comprehensive update across the codebase and documentation to standardize and simplify Terragrunt CLI flag names and environment variables. Legacy flags prefixed with --terragrunt- and environment variables prefixed with TERRAGRUNT_ have been replaced with shorter, more consistent forms (e.g., --non-interactive, TG_LOG_LEVEL). All code, test cases, and documentation references are updated accordingly. Additionally, some comments and error messages were revised to reflect these new names, and minor documentation corrections and clarifications were made. No functional or control flow changes were introduced.

Changes

Files/Paths (Grouped) Change Summary
cli/commands/run/flags.go Updated initialization of the tgPrefix variable to use only flags.TgPrefix, ignoring the original prefix parameter.
cli/flags/global/flags.go Updated warning comments for deprecated global flags, changing --terragrunt-no-auto-init to --no-auto-init.
config/config_helpers.go, config/dependency.go, config/errors.go, configstack/module.go, configstack/running_module.go, configstack/stack.go Updated comments, error messages, and log strings to use new flag and environment variable names (e.g., --source, TG_IAM_ROLE, --queue-include-external). No code logic changes.
docs-starlight/src/content/docs/04-reference/01-hcl/02-blocks.mdx, docs-starlight/src/content/docs/04-reference/01-hcl/04-functions.mdx Updated documentation examples and argument names for special flags (e.g., --terragrunt-quiet, --terragrunt-global-cache).
docs-starlight/src/content/docs/04-reference/02-cli/99-rules.mdx, docs-starlight/src/content/docs/05-troubleshooting/01-debugging.mdx Fixed whitespace, formatting, and corrected flag names (e.g., --inputs-debug).
docs/_docs/02_features/01-units.md, docs/_docs/02_features/02-stacks.md, docs/_docs/02_features/04-state-backend.md, docs/_docs/02_features/08-aws-authentication.md, docs/_docs/02_features/09-hooks.md, docs/_docs/02_features/11-runtime-control.md, docs/_docs/03_community/01-contributing.md, docs/_docs/04_reference/02-cli-options.md, docs/_docs/04_reference/06-experiments.md, docs/_docs/04_reference/09-logging.md, docs/_docs/05_troubleshooting/01-debugging.md, docs/_docs/06_migration_guides/01-migrating-from-root-terragrunt-hcl.md Updated documentation to use new flag and environment variable names, corrected examples, and improved clarity.
internal/cli/app.go, cli/app_test.go Updated example commands and test arguments to use new flag names.
tflint/tflint.go, test/fixtures/tflint/*/terragrunt.hcl Changed --terragrunt-external-tflint flag to --external-tflint in code and test fixtures.
test/helpers/package.go, test/integration_*_test.go, test/fixtures/tflint/*/terragrunt.hcl Updated all test helpers and integration tests to use the new flag and environment variable names, replacing all --terragrunt- and TERRAGRUNT_ prefixes with their new forms.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant FlagsParser
  participant AppLogic

  User->>CLI: Run terragrunt command with new flags (e.g., --non-interactive, --log-level)
  CLI->>FlagsParser: Parse CLI arguments
  FlagsParser->>AppLogic: Provide parsed flags (new names)
  AppLogic->>AppLogic: Execute logic using new flag/environment variable names
  AppLogic-->>User: Output results
Loading

Possibly related PRs

  • gruntwork-io/terragrunt#3866: Updates migration guide documentation to reflect CLI flag and command changes, directly related to this standardization.
  • gruntwork-io/terragrunt#3895: Refactors flag initialization in cli/commands/run/flags.go, overlapping with changes to flag construction in this PR.
  • gruntwork-io/terragrunt#3723: Introduces and refactors the run command and its flags, affecting the same logic and variables as this PR.

Suggested reviewers

  • levkohimins
  • yhakbar

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2596e31 and ab6c4e8.

📒 Files selected for processing (8)
  • configstack/running_module.go (1 hunks)
  • configstack/stack.go (1 hunks)
  • docs/_docs/02_features/04-state-backend.md (1 hunks)
  • docs/_docs/03_community/01-contributing.md (1 hunks)
  • docs/_docs/04_reference/02-cli-options.md (1 hunks)
  • test/helpers/package.go (3 hunks)
  • test/integration_regressions_test.go (3 hunks)
  • tflint/tflint.go (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • configstack/stack.go
  • test/helpers/package.go
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/_docs/03_community/01-contributing.md
  • docs/_docs/02_features/04-state-backend.md
  • docs/_docs/04_reference/02-cli-options.md
  • tflint/tflint.go
  • configstack/running_module.go
  • test/integration_regressions_test.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Pull Request has non-contributor approval
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

helpers.CopyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName, helpers.TerraformRemoteStateS3Region)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-log-level trace --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --log-level trace --non-interactive --working-dir "+rootPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Replace this.

environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, testFixtureOutputAll)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+environmentPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+environmentPath)
Copy link
Copy Markdown
Collaborator Author

@yhakbar yhakbar May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace this.

environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, testFixtureOutputAll)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+environmentPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+environmentPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Replace this


helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+mgmtEnvironmentPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+stageEnvironmentPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+mgmtEnvironmentPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace these

rootPath := util.JoinPath(tmpEnvPath, testFixtureAwsAccountAlias)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+rootPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace these.

rootPath := util.JoinPath(tmpEnvPath, testFixtureAwsGetCallerIdentity)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+rootPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace these.

stderr bytes.Buffer
)
helpers.RunTerragruntRedirectOutput(t, "terragrunt output-all --terragrunt-non-interactive --terragrunt-working-dir "+environmentPath, &stdout, &stderr)
helpers.RunTerragruntRedirectOutput(t, "terragrunt output-all --non-interactive --working-dir "+environmentPath, &stdout, &stderr)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace this.

environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, testFixtureOutputAll)

helpers.RunTerragrunt(t, "terragrunt validate-all --terragrunt-non-interactive --terragrunt-working-dir "+environmentPath)
helpers.RunTerragrunt(t, "terragrunt validate-all --non-interactive --working-dir "+environmentPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace this.

helpers.CopyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName, helpers.TerraformRemoteStateS3Region)

helpers.RunTerragrunt(t, "terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
helpers.RunTerragrunt(t, "terragrunt apply-all --non-interactive --working-dir "+rootPath)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace this.

err := helpers.RunTerragruntCommand(
t,
"terragrunt apply-all --terragrunt-source-update --terragrunt-non-interactive --terragrunt-working-dir "+rootPath,
"terragrunt apply-all --source-update --non-interactive --working-dir "+rootPath,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Replace this.

Copy link
Copy Markdown
Collaborator Author

@yhakbar yhakbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Please ignore the TODOs. Are the --terragrunt- prefix removals of HCL functions just something I missed?

@yhakbar yhakbar merged commit c812c17 into main May 2, 2025
18 of 21 checks passed
@yhakbar yhakbar deleted the fix/cleaning-up-old-flags branch May 2, 2025 13:37
@coderabbitai coderabbitai bot mentioned this pull request Jan 29, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants